import { Menu } from 'electron';
import log from 'electron-log';

function getTemplate() {
  return [
    {
      label: '应用',
      submenu: [
        { label:'隐藏',role: 'hide' },
        { label:'隐藏其它',role: 'hideothers' },
        { label:'显示',role: 'unhide' },
        { type: 'separator' },
        { label:'退出',role: 'quit' },
      ],
    },
    {
      label: '编辑',
      submenu: [
        { label:'撤销',role: 'undo' },
        { label:'重做',role: 'redo' },
        { type: 'separator' },
        { label:'剪切',role: 'cut' },
        { label:'复制',role: 'copy' },
        { label:'粘贴',role: 'paste' },
        { label:'全选',role: 'selectall' },
      ],
    },
    {
      label: '查看',
      submenu: [
        { label:'重载',role: 'reload' },
        { label:'开发者工具',role: 'toggledevtools' },
        { type: 'separator' },
        { label:'全屏',role: 'togglefullscreen' },
      ],
    },
    {
      role: 'window',
      label: '窗口',
      submenu: [
        { label:'最小化',role: 'minimize' },
        { label:'关闭',role: 'close' },
      ],
    },
  ];
}

export function init() {
  log.info('(menu) init');
  const menu = Menu.buildFromTemplate(getTemplate());
  Menu.setApplicationMenu(menu);
}
